<?php
/**
 * 访问所有接口的关口
 * @author solar
 */
class Gateway 
{
	public static function excute($module,$class,$method) {
		$proxy=ProxyFactory::get($class,$module);
		if($proxy===false || !method_exists($proxy,$method))
			return array('ikylin'=>self::NotFound);
		if(self::checkAuth($proxy,$method)===false)
			return array('ikylin'=>self::Unauthorized);
		return $proxy->$method();
	}
	
	public static function checkAuth($proxy,$method) {
		if(in_array($method,$proxy->noAuthMethod())) return true;
		if(ServiceFactory::get('UserService')->isLogined()) return true;
		return false;
	}
	
	//状态码
	const NotFound=8404;
	const Unauthorized=8401;
	const InternalError=8500;
	const ServiceUnavailable=8503;
}

?>